import { Column, ManyToOne, Entity } from "typeorm";
import { UserEntity } from "./user.entity";
import { CommonEntity } from "./common.entity";
import { Exclude } from "class-transformer";
import { ApiProperty } from "@nestjs/swagger";

@Entity({ name: "user_media" })
export class MediaEntity extends CommonEntity {
    @ApiProperty({ description: "媒体标题, 文件名" })
    @Column()
    title: string;

    @ApiProperty({ description: "文件路径" })
    @Column()
    filepath: string;

    @ApiProperty({ description: "媒体时长" })
    @Column()
    duration: number;

    @ApiProperty({ description: "已播放时长" })
    @Column()
    lastPosition: number;

    @Exclude()
    @ManyToOne((type) => UserEntity, (user) => user.medias)
    user: UserEntity;
}
